import axios from '../AxiosConfig.js'

export const createVhost = data => {
  return axios({
    method: 'put',
    url: '/api/vhosts/' + encodeURIComponent(data.name),
    data: data
  })
}

export const deleteVhost = data => {
  return axios({
    method: 'delete',
    url: '/api/vhosts/' + encodeURIComponent(data.name),
  })
}

export const listVhost = () => {
  return axios({
    method: 'get',
    url: '/api/vhosts'
  })
}

export const listVhostByName = (name) => {
  return axios({
    method: 'get',
    url: '/api/vhosts',
    params: {"name": name}
  })
}

export const listVhostPermission = (name) => {
  return axios({
    method: 'get',
    url: '/api/vhosts/' + encodeURIComponent(name) +'/permissions'
  })
}

export const listVhostTopicPermission = (name) => {
  return axios({
    method: 'get',
    url: '/api/vhosts/' + encodeURIComponent(name) +'/topic-permissions'
  })
}

export const listVhostConnection = (name) => {
  return axios({
    method: 'get',
    url: '/api/vhosts/' + encodeURIComponent(name) +'/connections'
  })
}

export const listVhostChannel = (name) => {
  return axios({
    method: 'get',
    url: '/api/vhosts/' + encodeURIComponent(name) +'/channels'
  })
}


